//
//  PersonalViewController.m
//  框架
//
//  Created by 这是工作本 on 15/12/25.
//  Copyright © 2015年 这是工作本. All rights reserved.
//

#import "PersonalViewController.h"


@interface PersonalViewController ()<UINavigationControllerDelegate, UIImagePickerControllerDelegate>

@property (nonatomic, retain) UIImageView *headView;

@property (nonatomic, retain) UIImageView *photo;

@property (nonatomic, retain) UIAlertController *alertC;

@property (nonatomic, retain) UITableView *tableV;

@property (nonatomic, retain) UIButton *Register;

@property (nonatomic, retain) UIButton *loging;

@property (nonatomic, retain) UIButton *order;

@property (nonatomic, retain) UIView *viewB;

@property (nonatomic, retain) UIButton *shop;

@property (nonatomic, retain) UIButton *pay;

@property (nonatomic, retain) UIButton *assessment;

@property (nonatomic, retain) UIButton *Refund;

@property (nonatomic, retain) UIButton *set;

@property (nonatomic, retain) UIButton *card;

@property (nonatomic, retain) UIButton *wallet;

@property (nonatomic, retain) UIButton *evaluation;

@property (nonatomic, retain) UIButton *collection;

@property (nonatomic, retain) UIButton *QRcode;
@end

@implementation PersonalViewController


- (void)viewDidAppear:(BOOL)animated
{
    
    self.tabBarController.tabBar.hidden = NO;

}

- (void)viewWillAppear:(BOOL)animated
{
    
 self.navigationController.navigationBarHidden = YES;

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //隐藏状态栏
    self.view.backgroundColor = [UIColor colorWithRed:240 / 255.0 green:240 / 255.0 blue:240 / 255.0 alpha:1.0];
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:29 / 255.0 green:127 / 255.0  blue:140 / 255.0  alpha:1.0];
    //设置navigationbar不透明
    self.navigationController.navigationBar.translucent = NO;
    
    
    //创建头视图(用户个人信息)
    
    self.headView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200 * ScreenHeigth)];
    self.headView.backgroundColor = [UIColor colorWithRed:29 / 255.0 green:127 / 255.0  blue:140 / 255.0  alpha:1.0];
    [self.view addSubview:self.headView];
    
    //二维码
    
    self.QRcode = [UIButton buttonWithType:UIButtonTypeCustom];
    self.QRcode.frame = CGRectMake(30 * ScreenWidth,  23 * ScreenHeigth, 22 * ScreenWidth, 22 * ScreenHeigth);
    [self.QRcode setImage:[UIImage imageNamed:@"iconfont-erweima.png"] forState:UIControlStateNormal];
    [self.QRcode addTarget:self action:@selector(QRcodeAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.QRcode];

    
    
    
    //设置
    
    self.set = [UIButton buttonWithType:UIButtonTypeCustom];
    self.set.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 30 * ScreenWidth,  23 * ScreenHeigth, 22 * ScreenWidth, 22 * ScreenHeigth);
    [self.set setImage:[UIImage imageNamed:@"形状-20@2x.png"] forState:UIControlStateNormal];
    [self.set addTarget:self action:@selector(SetAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.set];
    
    
    //用户头像
    self.photo = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width / 2 - 35 * ScreenWidth, 50 * ScreenHeigth, 70 * ScreenWidth, 70 * ScreenHeigth)];
    self.photo.layer.masksToBounds = YES;
    self.photo.layer.cornerRadius = 35 * ScreenWidth;
    
    //添加手势
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(photoChange)];
    self.photo.image = [UIImage imageNamed:@"椭圆-18@2x.png"];
    
    //图片交互
    self.photo.userInteractionEnabled = YES;
    [self.photo addGestureRecognizer:tap];
    [self.view addSubview:self.photo];
    
    
    //注册按钮
    
    self.Register = [UIButton buttonWithType:UIButtonTypeCustom];
    self.Register.frame = CGRectMake(95 * ScreenWidth, self.photo.frame.origin.y + self.photo.frame.size
                                     .height + 5 * ScreenHeigth, 100 * ScreenWidth, 30 * ScreenHeigth);
    [self.Register setImage:[UIImage imageNamed:@"注册@2x.png"] forState:UIControlStateNormal];
    [self.Register addTarget:self action:@selector(RegisterAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.Register];
    
    //登陆按钮
    self.loging = [UIButton buttonWithType:UIButtonTypeCustom];
    self.loging.frame = CGRectMake(self.Register.frame.origin.x + self.Register.frame.size.width + 30 * ScreenWidth, self.Register.frame.origin.y, 100 * ScreenWidth, 30 * ScreenHeigth);
    [self.loging setImage:[UIImage imageNamed:@"登录@2x.png"] forState:UIControlStateNormal];
    [self.loging addTarget:self action:@selector(logingAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.loging];
    
    //分割线
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, self.loging.frame.origin.y + self.loging.frame.size.height + 13 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 0.4 * ScreenHeigth)];
    view.backgroundColor = [UIColor colorWithRed:200 / 255.0 green:200 / 255.0 blue:200 / 255.0 alpha:1.0];
    [self.view addSubview:view];

    //提示语
    UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake(140 * ScreenWidth, 170 * ScreenHeigth, 150 * ScreenWidth, 30 * ScreenHeigth)];
    la.textColor = [UIColor colorWithRed:240 / 255.0 green:240 / 255.0  blue:240 / 255.0  alpha:1.0];
    la.text = @"登陆以后获得更多权力";
    la.font = [UIFont systemFontOfSize:13.0 * ScreenWidth];
    [self.headView addSubview:la];
    
    
    //我的订单
    self.order = [UIButton buttonWithType:UIButtonTypeCustom];
    self.order.frame = CGRectMake(0, self.headView.frame.origin.y + self.headView.frame.size.height + 10 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 50 * ScreenHeigth);
    //设置字体大小
    self.order.titleLabel.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
    [self.order setTitleColor:[UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0] forState:UIControlStateNormal];
    self.order.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.order setTitle:@"我的订单" forState:UIControlStateNormal];
    //设置字体靠左
    self.order.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //设置字体位置
    self.order.contentEdgeInsets = UIEdgeInsetsMake(0,10 * ScreenHeigth, 0, 0);

    [self.order addTarget:self action:@selector(orderAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.order];

    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 20 * ScreenWidth, self.order.frame.origin.y + 17 * ScreenHeigth, 8 * ScreenWidth, 12 * ScreenHeigth)];
    image.image = [UIImage imageNamed:@"形状-1-拷贝@2x.png"];
    [self.view addSubview:image];
    //背景
    self.viewB = [[UIView alloc] initWithFrame:CGRectMake(0, self.order.frame.origin.y + self.order.frame.size.height + 1 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 90 * ScreenHeigth)];
    self.viewB.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.view addSubview:self.viewB];
    
    //未消费
    
    self.shop = [UIButton buttonWithType:UIButtonTypeCustom];
    self.shop.frame = CGRectMake(36 * ScreenWidth, self.viewB.frame.origin.y + 23 * ScreenHeigth, 22 * ScreenWidth, 22 * ScreenHeigth);
    [self.shop setImage:[UIImage imageNamed:@"形状-24@2x.png"] forState:UIControlStateNormal];
    [self.shop addTarget:self action:@selector(RegisterAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.shop];

    UILabel *shop = [[UILabel alloc] initWithFrame:CGRectMake(27 * ScreenWidth, self.shop.frame.origin.y + self.shop.frame.size.height + 8 * ScreenHeigth, 50 * ScreenWidth, 13 * ScreenHeigth)];
    shop.text = @"未消费";
    shop.font = [UIFont systemFontOfSize:13.0 * ScreenWidth];
    shop.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [self.view addSubview:shop];
    
    
    //未付款
    
    self.pay = [UIButton buttonWithType:UIButtonTypeCustom];
    self.pay.frame = CGRectMake(self.shop.frame.origin.x + self.shop.frame.size.width + ([UIScreen mainScreen].bounds.size.width - 72 * ScreenWidth - 22 * ScreenWidth * 4) / 3 , self.shop.frame.origin.y , self.shop.frame.size.width, self.shop.frame.size.height);
    [self.pay setImage:[UIImage imageNamed:@"矩形-27@2x.png"] forState:UIControlStateNormal];
    [self.pay addTarget:self action:@selector(RegisterAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.pay];

    
    UILabel *pay = [[UILabel alloc] initWithFrame:CGRectMake(self.shop.frame.origin.x + self.shop.frame.size.width + 75 * ScreenWidth, shop.frame.origin.y, 50 * ScreenWidth, 13 * ScreenHeigth)];
    pay.text = @"未收款";
    pay.font = [UIFont systemFontOfSize:13.0 * ScreenWidth];
    pay.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [self.view addSubview:pay];

    
    //待评价

    self.assessment = [UIButton buttonWithType:UIButtonTypeCustom];
    self.assessment.frame = CGRectMake(self.pay.frame.origin.x + self.pay.frame.size.width + ([UIScreen mainScreen].bounds.size.width - 72 * ScreenWidth - 22 * ScreenWidth * 4) / 3 , self.shop.frame.origin.y , self.shop.frame.size.width, self.shop.frame.size.height);
    [self.assessment setImage:[UIImage imageNamed:@"形状-28@2x.png"] forState:UIControlStateNormal];
    [self.assessment addTarget:self action:@selector(RegisterAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.assessment];
    
    
    UILabel *assessment = [[UILabel alloc] initWithFrame:CGRectMake(pay.frame.origin.x + pay.frame.size.width + 63 * ScreenWidth, shop.frame.origin.y, 50 * ScreenWidth, 13 * ScreenHeigth)];
    assessment.text = @"待评价";
    assessment.font = [UIFont systemFontOfSize:13.0 * ScreenWidth];
    assessment.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [self.view addSubview:assessment];

    
    
   //退款
   
    self.Refund = [UIButton buttonWithType:UIButtonTypeCustom];
    self.Refund.frame = CGRectMake(self.assessment.frame.origin.x + self.assessment.frame.size.width + ([UIScreen mainScreen].bounds.size.width - 72 * ScreenWidth - 22 * ScreenWidth * 4) / 3 , self.shop.frame.origin.y , self.shop.frame.size.width, self.shop.frame.size.height);
    [self.Refund setImage:[UIImage imageNamed:@"矩形-28@2x.png"] forState:UIControlStateNormal];
    [self.Refund addTarget:self action:@selector(RegisterAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.Refund];

    
    UILabel *Refund = [[UILabel alloc] initWithFrame:CGRectMake(assessment.frame.origin.x + assessment.frame.size.width + 60 * ScreenWidth, shop.frame.origin.y, 50 * ScreenWidth, 13 * ScreenHeigth)];
    Refund.text = @"退款";
    Refund.font = [UIFont systemFontOfSize:13.0 * ScreenWidth];
    Refund.textColor = [UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0];
    [self.view addSubview:Refund];

    //场馆会员卡
    
    self.card = [UIButton buttonWithType:UIButtonTypeCustom];
    self.card.frame = CGRectMake(0, self.viewB.frame.origin.y + self.viewB.frame.size.height + 10 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 50 * ScreenHeigth);
    //设置字体大小
    self.card.titleLabel.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
    [self.card setTitleColor:[UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0] forState:UIControlStateNormal];
    self.card.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.card setTitle:@"场馆会员卡" forState:UIControlStateNormal];
    //设置字体靠左
    self.card.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //设置字体位置
    self.card.contentEdgeInsets = UIEdgeInsetsMake(0,35 * ScreenWidth, 0, 0);
    
    [self.card addTarget:self action:@selector(orderAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.card];
    
    
    //图标
    UIImageView *card = [[UIImageView alloc] initWithFrame:CGRectMake(10, self.viewB.frame.origin.y + self.viewB.frame.size.height + 25 * ScreenHeigth, 20 * ScreenWidth, 20 * ScreenHeigth)];
    card.image = [UIImage imageNamed:@"矩形-29@2x.png"];
    [self.view addSubview:card];
    

    UIImageView *imageC = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 20 * ScreenWidth, self.card.frame.origin.y + 17 * ScreenHeigth, 8 * ScreenWidth, 12 * ScreenHeigth)];
    imageC.image = [UIImage imageNamed:@"形状-1-拷贝@2x.png"];
    [self.view addSubview:imageC];

    
    //我的钱包
    
    self.wallet = [UIButton buttonWithType:UIButtonTypeCustom];
    self.wallet.frame = CGRectMake(0, self.card.frame.origin.y + self.card.frame.size.height + 10 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 50 * ScreenHeigth);
    //设置字体大小
    self.wallet.titleLabel.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
    [self.wallet setTitleColor:[UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0] forState:UIControlStateNormal];
    self.wallet.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.wallet setTitle:@"我的钱包" forState:UIControlStateNormal];
    //设置字体靠左
    self.wallet.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //设置字体位置
    self.wallet.contentEdgeInsets = UIEdgeInsetsMake(0,35 * ScreenWidth, 0, 0);
    
    [self.wallet addTarget:self action:@selector(orderAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.wallet];
    
    
    //图标
    UIImageView *wallet = [[UIImageView alloc] initWithFrame:CGRectMake(10 * ScreenWidth, self.wallet.frame.origin.y + 15 * ScreenHeigth, 20 * ScreenWidth, 20 * ScreenHeigth)];
    wallet.image = [UIImage imageNamed:@"椭圆-23@2x.png"];
    [self.view addSubview:wallet];

    UIImageView *imageW = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 20 * ScreenWidth, self.wallet.frame.origin.y + 17 * ScreenHeigth, 8 * ScreenWidth, 12 * ScreenHeigth)];
    imageW.image = [UIImage imageNamed:@"形状-1-拷贝@2x.png"];
    [self.view addSubview:imageW];

    
    //我的评价
    
    
    self.evaluation = [UIButton buttonWithType:UIButtonTypeCustom];
    self.evaluation.frame = CGRectMake(0, self.wallet.frame.origin.y + self.wallet.frame.size.height + 1 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 50 * ScreenHeigth);
    //设置字体大小
    self.evaluation.titleLabel.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
    [self.evaluation setTitleColor:[UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0] forState:UIControlStateNormal];
    self.evaluation.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.evaluation setTitle:@"我的评价" forState:UIControlStateNormal];
    //设置字体靠左
    self.evaluation.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //设置字体位置
    self.evaluation.contentEdgeInsets = UIEdgeInsetsMake(0,35 * ScreenWidth, 0, 0);
    
    [self.evaluation addTarget:self action:@selector(orderAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.evaluation];
    
    
    //图标
    UIImageView *evaluation = [[UIImageView alloc] initWithFrame:CGRectMake(10 * ScreenWidth, self.evaluation.frame.origin.y + 15 * ScreenHeigth, 20 * ScreenWidth, 20 * ScreenHeigth)];
    evaluation.image = [UIImage imageNamed:@"椭圆-23-拷贝-2@2x.png"];
    [self.view addSubview:evaluation];

    UIImageView *imageE = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 20 * ScreenWidth, self.evaluation.frame.origin.y + 17 * ScreenHeigth, 8 * ScreenWidth, 12 * ScreenHeigth)];
    imageE.image = [UIImage imageNamed:@"形状-1-拷贝@2x.png"];
    [self.view addSubview:imageE];

    
    
    //我的收藏
    
    
    self.collection = [UIButton buttonWithType:UIButtonTypeCustom];
    self.collection.frame = CGRectMake(0, self.evaluation.frame.origin.y + self.evaluation.frame.size.height + 1 * ScreenHeigth, [UIScreen mainScreen].bounds.size.width, 50 * ScreenHeigth);
    //设置字体大小
    self.collection.titleLabel.font = [UIFont systemFontOfSize:15.0 * ScreenWidth];
    self.collection.backgroundColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1.0];
    [self.collection setTitle:@"我的收藏" forState:UIControlStateNormal];
    [self.collection setTitleColor:[UIColor colorWithRed:30 / 255.0 green:30 / 255.0 blue:30 / 255.0 alpha:1.0] forState:UIControlStateNormal];
   
    //设置字体靠左
    self.collection.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    //设置字体位置
    self.collection.contentEdgeInsets = UIEdgeInsetsMake(0,35 * ScreenWidth, 0, 0);
    
    [self.collection addTarget:self action:@selector(orderAction:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.collection];
    
    //图标
    UIImageView *collection = [[UIImageView alloc] initWithFrame:CGRectMake(10 * ScreenWidth, self.collection.frame.origin.y + 15 * ScreenHeigth, 20 * ScreenWidth, 20 * ScreenHeigth)];
    collection.image = [UIImage imageNamed:@"多边形-1@2x.png"];
    [self.view addSubview:collection];

    UIImageView *imageN = [[UIImageView alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 20 * ScreenWidth, self.collection.frame.origin.y + 17 * ScreenHeigth, 8 * ScreenWidth, 12 * ScreenHeigth)];
    imageN.image = [UIImage imageNamed:@"形状-1-拷贝@2x.png"];
    [self.view addSubview:imageN];
    
    
    //弹出选择
    //拍照
    self.alertC = [[UIAlertController alloc] init];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
        
        
    }];
    
    //拍照
    UIAlertAction *photo = [UIAlertAction actionWithTitle:@"拍照" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
            
            UIImagePickerController *pick = [[UIImagePickerController alloc] init];
            pick.delegate = self;
            pick.allowsEditing = YES;
            pick.sourceType = UIImagePickerControllerSourceTypeCamera;
            [self presentViewController:pick animated:YES completion:^{
                
                
            }];
            
        } else {
            
            NSLog(@"没有相机");
        }
        
    }];
    
    //从相册选取
    
    UIAlertAction *photograph = [UIAlertAction actionWithTitle:@"从相册中选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        [self presentViewController:imagePicker animated:YES completion:nil];
        
    }];
    
    [self.alertC addAction:action];
    [self.alertC addAction:photo];
    [self.alertC addAction:photograph];
  
    //添加手势
    UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(change)];
    
    [self.headView addGestureRecognizer:gesture];
    
   

    
   
    
    
    //个人信息
    
//    self.tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, self.headView.frame.origin.y + self.headView.frame.size.height, self.view.frame.size.width, self.view.frame.size.height - self.headView.frame.size.height - 64 - 49) style:UITableViewStylePlain];
//    self.tableV.delegate = self;
//    self.tableV.dataSource = self;
    
//    //解决左边空白问题
//    if ([self.tableV respondsToSelector:@selector(setSeparatorInset:)]) {
//        
//        [self.tableV setSeparatorInset:UIEdgeInsetsZero];
//    }
//    
//    if ([self.tableV respondsToSelector:@selector(setLayoutMargins:)])
//    {
//        [self.tableV setLayoutMargins:UIEdgeInsetsZero];
//    }
//    
//
    
}




- (void)RegisterAction:(UIButton *)sender
{
    //添加水波动画
    CATransition *ansition = [CATransition animation];
    ansition.duration = 1.0;
    ansition.type = @"rippleEffect";
    [self.view.window.layer addAnimation:ansition forKey:nil];

    bbbViewController *b = [[bbbViewController alloc] init];
    [self.navigationController pushViewController:b animated:YES];
    
    
}

//登陆
- (void)logingAction:(UIButton *)sender
{
    //添加水波动画
    CATransition *ansition = [CATransition animation];
    ansition.duration = 1.0;
    ansition.type = @"rippleEffect";
    [self.view.window.layer addAnimation:ansition forKey:nil];

    aaaViewController *a = [[aaaViewController alloc] init];
    
    [self.navigationController pushViewController:a animated:YES];
    
}

- (void)orderAction:(UIButton *)sender
{
    
    
}



//代理方法解决15像素空白问题

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)])
    {
        [cell setSeparatorInset:UIEdgeInsetsZero];
    }
    if ([cell respondsToSelector:@selector(setLayoutMargins:)])
    {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

- (void)photoChange
{
    //模态推出
    [self presentViewController:self.alertC animated:YES completion:^{
        
    }];
}

#pragma mark - 转换图片的尺寸
+ (UIImage *)imageWithImageSimple:(UIImage*)image scaledToSize:(CGSize) newSize{
    
    newSize.height=image.size.height*(newSize.width/image.size.width);
    
    UIGraphicsBeginImageContext(newSize);
    
    [image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
    
    UIImage *newImage=UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    
    return  newImage;
    
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
{
    UIImage *image = info[@"UIImagePickerControllerOriginalImage"];
    [self.photo setImage:image];
    
    //上传到服务器
    //改变尺寸
    [[self class]imageWithImageSimple:image scaledToSize:CGSizeMake(500, 500)];
    NSData *_data = UIImageJPEGRepresentation(image,0.05f);
    NSString *_encodedImageStr = [_data base64Encoding];
    
    
    NSLog(@"%@", image);
    NSDictionary *headerDict = @{@"file":_encodedImageStr, @"tradeType":@"_userPhoto"};
//    NSArray *imageArr = [NSArray arrayWithObjects:image, nil];
    [[NetworkSingleton sharedManager] upImageWithParameter:headerDict imageArray:nil url:@"http://192.168.1.157:8080/api/center?userId=&equipment=ios&requestType=FileUpload_Api&token=" successBlock:^(id responseBody) {
        
        NSLog(@"上传头像成功");
        
    } failureBlock:^(NSString *error) {
        
        NSLog(@"上传头像失败");

        
    }];
    
    
    [picker dismissViewControllerAnimated:YES completion:nil];
    
    
}




- (void)change
{
    
    //添加水波动画
    CATransition *ansition = [CATransition animation];
    ansition.duration = 1.0;
    ansition.type = @"rippleEffect";
    [self.view.window.layer addAnimation:ansition forKey:nil];


    
    DetailPersonViewController *detail = [[DetailPersonViewController alloc] init];
    
    [self.navigationController pushViewController:detail animated:YES];
    
    
}

- (void)SetAction:(UIButton *)sender
{
    //添加翻页动画
    CATransition *ansition = [CATransition animation];
    ansition.duration = 1.0;
    ansition.type = @"pageCurl";
    [self.view.window.layer addAnimation:ansition forKey:nil];
    
    SetViewController *set = [[SetViewController alloc] init];
    [self.navigationController pushViewController:set animated:YES];
    
    
}





- (void)QRcodeAction:(UIButton *)sender
{
    //添加翻页动画
    CATransition *ansition = [CATransition animation];
    ansition.duration = 1.0;
    ansition.type = @"pageCurl";
    [self.view.window.layer addAnimation:ansition forKey:nil];
    ;

    CtrlCodeScan *ctr = [[CtrlCodeScan alloc] init];
    [self.navigationController pushViewController:ctr animated:YES];
    
    
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
